package com.base.home.adapter;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;

import com.base.commonlib.recy.BaseHolderType;
import com.base.commonlib.recy.BasicRecyViewHolder;
import com.base.home.HomeConfig;
import com.base.home.R;
import com.base.home.bean.ConcertSelectEntity;
import com.base.commonlib.recy.HorizonRecyclerView;

import java.util.List;

/**
 * 精选课程
 *
 * @version V1.0 <描述当前版本功能>
 *          Created by admin on 2018/5/22.
 * @FileName: com.zhongyue.mdchengguan.ui.main.adapter.CategoryViewHolder.java
 * Author weikailiang
 * @date: 2018-05-22 14:22
 */
public class CoursewareViewHolder extends BaseHolderType<List<ConcertSelectEntity.RecentLearnBean>,CoursewareViewHolder.coursewareViewHolder> {

    @Override
    public int getType(List<ConcertSelectEntity.RecentLearnBean> beans) {
        return HomeConfig.COURSEWARE;
}

    @Override
    public void bindDataToHolder(final coursewareViewHolder holder, List<ConcertSelectEntity.RecentLearnBean> bean, int postion) {
        holder.mCourseAdapter.refreshDatas(bean);
    }



    @Override
    public coursewareViewHolder buildHolder(ViewGroup parent) {
        return new coursewareViewHolder(View.inflate(parent.getContext(), R.layout.item_course, null));
    }



    public static class coursewareViewHolder extends BasicRecyViewHolder {
//        private HorizontalScrollView horizon;
        private HorizonRecyclerView mRecycler;
        private CourseAdapter mCourseAdapter;
        public coursewareViewHolder(View itemView) {
            this(itemView, null, null);
            mRecycler = itemView.findViewById(R.id.recycler);
//            horizon = itemView.findViewById(R.id.horizon);
//            UITools.elasticPadding(horizon,300);
            if (mCourseAdapter == null){
                mCourseAdapter = new CourseAdapter(R.layout.item_courseware);
                mRecycler.setAdapter(mCourseAdapter);
                RecyclerView.LayoutManager mLinearment = new LinearLayoutManager(mRecycler.getContext(),LinearLayoutManager.VERTICAL,false);
                mRecycler.setLayoutManager(mLinearment);
            }
        }
        public coursewareViewHolder(View itemView, OnItemClickListener clickListener, OnItemLongClickListener longClickListener) {
            super(itemView, clickListener, longClickListener);
        }
    }
}
